package nevo.pkgs.neuro.bio;

/**
 * A pool of random numbers.
 * 
 * @author mschachter
 *
 */
public class RandomPool
{	
	protected double[] rnums;
	
	protected int index;
	
	protected int size;
	
	public RandomPool(int s)
	{
		rnums = new double[s];
		size = s;
		fillPool();
	}
	
	public synchronized double getRandom()
	{
		if (index >= rnums.length)  fillPool();		
		index++;
		return rnums[index-1];
	}
		
	protected void fillPool()
	{	
		for (int k = 0; k < size; k++) {
			rnums[k] = Math.random();
		}			
		index = 0;
	}
}
